#ifndef __UIDLGBUILDER_H__
#define __UIDLGBUILDER_H__

#pragma once

#include "xmldrv3/xmldrv.h"

namespace dui {

class UIFrameBuilderDelegate
{
public:
    virtual UIWidget* CreateWidget(LPCTSTR pstrClass) = 0;
};


class DUILIB_API UIFrameBuilder
{
public:
    UIFrameBuilder();
    UIWidget* Build(const char* xml, LPCTSTR type = NULL, UIFrameBuilderDelegate* pCallback = NULL,
        UIRenderManager* pManager = NULL, UIWidget* pParent = NULL);

    UIWidget* Build(UINT resId, LPCTSTR type = NULL, UIFrameBuilderDelegate* pCallback = NULL,
        UIRenderManager* pManager = NULL, UIWidget* pParent = NULL);

    UIWidget* Build(UIFrameBuilderDelegate* pCallback = NULL, UIRenderManager* pManager = NULL,
        UIWidget* pParent = NULL);

    xmld::document& GetMarkup();
private:
    UIWidget* _Parse(const xmld::element& parent, UIWidget* pParent = NULL, UIRenderManager* pManager = NULL);

    // CMarkup m_xml;
    xmld::document m_xmlNew;
    UIFrameBuilderDelegate* m_pCallback;
    LPCTSTR m_pstrtype;
};

} // namespace dui

#endif // __UIDLGBUILDER_H__
